package java04;

import java.util.Arrays;
import java.util.Scanner;

public class Main03 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayIntegerStack MyStack = new ArrayIntegerStack(n);
		int m = in.nextInt();
		for (int i = 0; i < m; i++) {
			Integer number = in.nextInt();
			System.out.println(MyStack.push(number));
		}
		System.out.print(MyStack.peek() + "," + MyStack.empty() + ","
				+ MyStack.size() + "\n");
		System.out.println(Arrays.toString(MyStack.getStack()));
		int x = in.nextInt();
		for (int i = 0; i < x; i++) {
			System.out.println(MyStack.pop());
		}
		System.out.print(MyStack.peek() + "," + MyStack.empty() + ","
				+ MyStack.size() + "\n");
		System.out.println(Arrays.toString(MyStack.getStack()));
	}

}


